<template>
	<div style="display: flex;flex-direction: column;" class="otherPage partyBuildingLeads partyBuildingInNewsList">
		<Header :selected="2"></Header>
		<div class="bannerArea">
			<div class="banner" :style="bg_img? 'background:url('+bg_img+') no-repeat;background-size:cover;':''">

			</div>
		</div>
		<Navigation v-loading="loading" :items="breadcrumbItems" :menus="menus" :bgColor="bgColor" :checked="1">
		</Navigation>
		<div class="content" style="min-height: 600px;">
			<div class="content_bg" style="min-height: 600px;">
				<el-row>
					<el-col class="partyBuildingInNewsTitle">
						{{newsData.now.title}}
					</el-col>
					<el-col class="partyBuildingInNewsDate">
						{{$t("releaseDate")}}{{newsData.now?"："+newsData.now.createTime:""}}
					</el-col>
					<!-- <el-col class="partyBuildingInNewsDescription" v-if="newsData.fileUrl!=''">
						<div class="partyBuildingInNewsArea" style="">
							<img :src="newsData.fileUrl" style="object-fit: cover;width: 100%; height:70vh;" />
						</div>
					</el-col> -->
					<el-col class="partyBuildingInNewsDescription" v-html="newsData.now.content.setWrap()">
					</el-col>

				</el-row>
				<el-row class="pageupOrNext" :gutter="10">
					<el-col :xs="24" :sm="12" :md="12" :lg="12">
						<div v-if="newsData.previous" @click="goToDetail(newsData.previous.id)"
							class="newsOtherTitle textAlignLeft">
							{{$t('previousArticle')}}{{newsData.previous.title||''}}

						</div>
						<div v-else class="noOtherTitle textAlignLeft">{{$t('previousArticle')}}{{$t('noMoreTitle')}}
						</div>
					</el-col>
					<el-col :xs="24" :sm="12" :md="12" :lg="12">
						<div v-if="newsData.next" @click="goToDetail(newsData.next.id)"
							class="newsOtherTitle textAlignRight">
							{{$t('nextArticle')}}{{newsData.next.title||''}}
						</div>
						<div v-else class="noOtherTitle textAlignRight">{{$t('nextArticle')}}{{$t('noMoreTitle')}}</div>

					</el-col>
				</el-row>
			</div>
		</div>
		<Footer></Footer>
	</div>
</template>

<script>
	import Header from '../../../src/components/common/header/Header.vue'
	import Navigation from '../../../src/components/common/navigation/Navigation.vue'
	import Footer from '../../../src/components/common/footer/Footer.vue'
	import Pagination from '../../../src/components/common/Pagination.vue'
	import {
		partyBuildingLeads
	} from '../../utils/menu.js'
	export default {
		components: {
			Header,
			Navigation,
			Footer,
			Pagination
		},
		data() {
			return {
				loading: true,
				bg_img: '', //头部banner，默认值已绑定，有背景自动切换
				bgColor: "white", //white/red
				id: '',
				menus: partyBuildingLeads,
				breadcrumbItems: [{
						//首页
						label: this.$t('home'),
						to: '/home'
					},
					{
						//党建引领
						label: this.$t('partyBuildingLeads'),
						to: '/partyBuildingLeads'
					},
					{
						//党建资讯
						label: this.$t('partyBuildingInformation'),
						to: '/partyBuildingInNewsList'
					}
				],
				newsCarousel: [{
						imageUrl: '',
						title: ''

					},
					{
						imageUrl: '',
						title: ''

					}, {
						imageUrl: '',
						title: ''

					}
				],

				newsData: {
					now: {
						id: '',
						title: '',
						content: '',
						createTime: '',
						fileUrl: ''
					},
					next: {
						id: "",
						title: ""
					},
					previous: {
						id: "",
						title: ""
					}

				},
				hoverIndex: -1
			};
		},
		computed: {},
		created() {},
		mounted() {
			this.id = this.$route.query.id;
			//获取banner
			this.getPartyInfoTopImage();
			this.getPartyInfoDetail().then(i => {
				this.$request.setImageMaxwidth("img");
			});;

		},
		methods: {
			/**
			 * 获取banner图片
			 */
			getPartyInfoTopImage() {
				let params = {};
				let that = this;
				that.$request.getPartyInfoTopImage(params).then(res => {
					if (res && res.data) {
						that.bg_img = res.data.fileUrl;
					}
				}).catch((error) => {
					console.log(error);
				});
			},
			formatDate(date, format) {
				// 自定义日期格式化方法
				// 可以使用moment.js或其他日期处理库来进行格式化
			},
			//partyMemberActivitiesDetail

			getPartyInfoDetail() {
				return new Promise((resolve, reject) => {
					let params = {
						"partyInfoId": this.id, //党建资讯id

					};
					let that = this;
					that.$request.getPartyInfoDetail(params).then(res => {
						if (res && res.data) {
							that.newsData = res.data;
						}
						this.loading = false;
						resolve();
					}).catch((error) => {
						console.log(error);
					});
				});
			},
			//////跳转详情页面
			goToDetail(id) {
				this.bindDetail(id).then(i=>{
					this.$request.setImageMaxwidth("img");
				});
			},
			bindDetail(id){
				this.id = id;
				return new Promise((resolve, reject) => {
					let params = {
						"partyInfoId": id, //党建资讯id
				
					};
					let that = this;
					that.$request.getPartyInfoDetail(params).then(res => {
						if (res && res.data) {
							that.newsData = res.data;
						}
						this.loading = false;
						resolve();
						// 页面跳转后让滚动条置顶
						this.scrollToTop();
					}).catch((error) => {
						console.log(error);
					});
				});
			},
			scrollToTop() {
				const currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
				if (currentScroll > 0) {
					window.requestAnimationFrame(this.scrollToTop);
					window.scrollTo(0, currentScroll - currentScroll / 5);
				}
			}
		}
	}
</script>

<style scoped>
	@import url("../../components/common/css/partyBuildingLeads/partyBuildingLeads.css");

	.partyBuildingInNewsTitle {
		height: max-content;
		line-height: 40px;
		font-size: 20px;
		text-align: center;
		font-weight: 530;
		color: #333333;
	}

	.partyBuildingInNewsDate {
		text-align: center;
		height: 40px;
		line-height: 40px;
		font-weight: 400;
		color: #999999;
		line-height: 33px;
	}

	.partyBuildingInNewsDescription {
		font-size: 16px;
		font-weight: 400;
		/* color: #666666; */
		line-height: 27px;
		overflow: hidden;
	}

	.partyBuildingInNewsArea {
		width: 70%;
		height: 70vh;
		margin-left: 15%;
		margin-bottom: 4vh;
	}

	.partyBuildingInNewsList .newsOtherTitle {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		cursor: pointer;
		font-size: 16px;
		text-decoration: underline;
		height: 70px;
		line-height: 100px;
	}

	.partyBuildingInNewsList .noOtherTitle {
		color: #999;
		text-decoration: none;
		opacity: 0.6;
		height: 70px;
		line-height: 100px;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		cursor: pointer;
		font-size: 16px;
	}

	.partyBuildingInNewsList .newsOtherTitle:hover {
		color: #0484D7;
	}

	.partyBuildingInNewsList .newsOtherTitle.textAlignLeft,
	.partyBuildingInNewsList .noOtherTitle.textAlignLeft {
		text-align: left;
		position: absolute;
		left: -40px;
		bottom: 0px;
		width: 30%;
	}

	.partyBuildingInNewsList .newsOtherTitle.textAlignRight,
	.partyBuildingInNewsList .noOtherTitle.textAlignRight {
		text-align: right;
		position: absolute;
		right: -40px;
		bottom: 0px;
		width: 30%;
	}

	.partyBuildingLeads .content {
		padding: 0;
	}

	.content_bg {
		margin: 0px auto;
		padding: 50px;
	}

	.partyBuildingInNewsList .pageupOrNext {
		display: flex;
		position: relative;
		height: 70px;
	}

	@media (min-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}
	}

	@media (max-width: 2560px) {
		.content_bg {
			width: calc(2560px * 0.8);
		}
	}

	@media (max-width: 2320px) {
		.content_bg {
			width: calc(2320px * 0.8);
		}
	}

	@media (max-width: 2120px) {
		.content_bg {
			width: calc(2120px * 0.8);
		}
	}

	@media (max-width: 1920px) {
		.content_bg {
			width: calc(1920px * 0.8);
		}

		.companyCultureImgArea {
			width: 60%;
		}

		.companyCultureContent {}

	}

	@media (max-width: 1720px) {


		.content_bg {
			width: calc(1720px * 0.8);
		}
	}

	@media (max-width: 1520px) {
		.content_bg {
			width: calc(1520px * 0.8);
		}
	}

	@media (max-width: 1366px) {
		.content_bg {
			width: calc(1366px * 0.8);
		}
	}

	@media (max-width: 1120px) {
		.content_bg {
			width: 100%
		}
	}

	@media (max-width: 1024px) {}

	@media (max-width: 900px) {}

	@media(max-width:768px) {
		.partyBuildingInNewsArea {
			width: 90%;
			height: 70vh;
			margin-left: 5%;
			margin-bottom: 4vh;
		}

		.partyBuildingInNewsList .noOtherTitle.textAlignLeft,
		.partyBuildingInNewsList .newsOtherTitle.textAlignLeft {
			left: 0px;
		}

		.partyBuildingInNewsList .noOtherTitle.textAlignRight,
		.partyBuildingInNewsList .newsOtherTitle.textAlignRight {
			right: 0px;
		}

		.partyBuildingInNewsList .pageupOrNext {
			display: flex;
			position: relative;
			height: 70px;
		}
	}

	@media(max-width:440px) {

		.partyBuildingInNewsList .pageupOrNext {
			flex-direction: column;
			height: max-content;
		}

		.partyBuildingInNewsList .newsOtherTitle {
			line-height: 70px;
		}
.partyBuildingInNewsList .noOtherTitle.textAlignRight,
		.partyBuildingInNewsList .noOtherTitle.textAlignLeft,
		.partyBuildingInNewsList .newsOtherTitle.textAlignLeft,
		.partyBuildingInNewsList .newsOtherTitle.textAlignRight {
			right: 0px;
			position: unset;
			width: 100%;
			text-align: center;
		}
	}
</style>
